package io.renren.modules.visit.controller;

import io.renren.common.utils.PageUtils;
import io.renren.common.utils.ResponseModel;
import io.renren.modules.app.service.UserService;
import io.renren.modules.sys.controller.AbstractController;
import io.renren.modules.sys.entity.ContentEntity;
import io.renren.modules.sys.entity.GameModuleEntity;
import io.renren.modules.sys.entity.SysUserEntity;
import io.renren.modules.sys.service.ContentService;
import io.renren.modules.sys.service.GameModuleService;
import io.renren.modules.sys.vo.ContentVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("visit")
@Api(tags = "无登录访问")
public class VisitController extends AbstractController {

    @Autowired
    private GameModuleService gameModuleService;

    @Autowired
    private UserService userService;

    @Autowired
    private ContentService contentService;

    @GetMapping("/mk/{mbid}")
    @ApiOperation("根据模板id获取模块")
    public ResponseModel<List<GameModuleEntity>> getModuleByMkid(@PathVariable("mbid") Long mbid) {
        List<GameModuleEntity> list = gameModuleService.getModuleByMkid(mbid);
        return ResponseModel.of(list);
    }

    /**
     * 游戏模板
     */
    @PostMapping("/column")
    @ApiOperation("过滤")
    public ResponseModel<GameModuleEntity> filterBycolumn(@RequestBody GameModuleEntity params) {
        GameModuleEntity gameModule = gameModuleService.filterByColumn(params);
        return ResponseModel.of(gameModule);
    }

    /**
     * 人员管理分组1
     */
    @GetMapping("/ryglGroup")
    @ApiOperation("人员管理-分组")
    public ResponseModel<List> rygl1() {
        List<Map> list = userService.regl1();
        return ResponseModel.of(list);
    }

    /**
     * 人员管理分组1
     */
    @GetMapping("/ryglGroup2")
    @ApiOperation("人员管理-分组")
    public ResponseModel<List> rygl2() {
        List<Map> list = userService.regl2();
        return ResponseModel.of(list);
    }

    @PostMapping("/listAllContent")
    @ApiOperation("列表-全")
    public ResponseModel<List<ContentEntity>> listAll(@RequestBody ContentVo content) {
        List<ContentEntity> list = contentService.listAll(content);
        return ResponseModel.of(list);
    }

}
